﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using LF3.Moduls;
using CP.DBService;
using Oracle.ManagedDataAccess.Client;
using System.Data;

namespace LF3.Repositories
{
    public class Operate_LogRepository
    {
        DBHelper db = DBHelper.CreateInstance();
         
        public IList<Operate_Log> GetOperateLogCondition(string condition)
        {
            return db.ExecuteObject<Operate_Log>(string.Format(@"select * from Operate_Log where 1=1 " +
                                                condition +
                                                " order by op_date"));
        }

        public IList<Lf_Heat_Event> GetHeatEventCondition(string condition)
        {
            return db.ExecuteObject<Lf_Heat_Event>(string.Format(@"select * from LF_HEAT_EVENT where 1=1 " +
                                                condition +
                                                " order by INSERT_TIME"));
        }

        public IList<Plc_Mat> GetPlcMatCondition(string condition)
        {
            return db.ExecuteObject<Plc_Mat>(string.Format(@"SELECT t1.*, T3.MATERIALDESC
                              FROM PLC_MAT t1, LF_MATERIAL_BUNKER t2, LF_MATERIAL_INFO t3
                             WHERE     SUBSTR (T1.TAGNAME, 15, 2) = t2.bunkerno
                                   AND T2.MATERIALCODE = T3.MATERIALCODE  " +
                                                condition + " order by INSERTTIME"));
        }

        public IList<Lf_Event_Code> GetAllCode()
        {
            return db.ExecuteObject<Lf_Event_Code>("select * from lf_event_code");
        }
    }
}
